package com.anchovy.maven.service;

import com.anchovy.maven.entity.User;
import com.anchovy.maven.mapper.UserMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {


/*    @Autowired
    private UserMapper userMapper;*/

    /**
     * 保存用户信息
     *
     * @param user 待保存的用户对象
     */
    @Override
    public void saveUser(User user) {
        //userMapper.insert(user);
        save(user);
        log.info("UserServiceImpl.saveUser={}", user.toString());
    }

    /**
     * 根据用户ID查找用户
     *
     * @param id 用户ID
     * @return 查找到的用户对象
     */
    @Override
    public User findUserById(Integer id) {
        //User user = userMapper.selectById(id);
        User user = getById(id);
        log.info("UserServiceImpl.findUserById={}", user.toString());
        return user;
    }

}
